package com.ibm.dao;



import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
//import java.sql.Statement;
import java.util.ArrayList;

import com.ibm.bean.News;

public class NewsDao {
	private Connection conn;
//	private Statement s;
	private PreparedStatement ps;
	private DbConn dbconn = new DbConn();
	
	
	
	
	
	public ArrayList<News> getNewsAll(){
		return null;
	}
	
	public boolean insertNews(News news){
		conn = dbconn.getConn();
		
		String sql = "insert into tb_news (id, sortId, content, createTime, bigSort, title) values (?, ?, ?, ?, ?, ?)";
		try {
			ps = conn.prepareStatement(sql);
			ps.setInt(1, news.getId());
			ps.setInt(2, news.getSortId());
			ps.setString(3, news.getContent());
			ps.setString(4, news.getCreateTime());
			ps.setString(5, news.getBigSort());
			ps.setString(6, news.getTitle());
			
			if (ps.executeUpdate() > 0) {
				return true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			dbconn.freeConn(conn, ps, null);
		}
		return false;
	}
	
	public boolean updateNews(News news){
		return false;
	}
	
	public boolean deleteNews(int id){
		return false;
	}
	
	
}
